home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 009 / proff / putwrd.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  983b  |  53 lines

  1.  
  2.  
  3.  
  4.  
  5. #include <stdio.h>
  6. #include "proff.h"
  7. #include "debug.h"
  8.  
  9. /*
  10.  * putwrd - put a word in outbuf; includes margin justification
  11.  *
  12.  */
  13. putwrd(wrdbuf)
  14. char wrdbuf[];
  15. {
  16.     int last, llval, extra, w;
  17.  
  18. dprintf("putwrd  ");
  19.     w = width(wrdbuf);
  20.     last = strlen(wrdbuf) + outp;         /* new end of outbuf */
  21. #ifdef DEBUG
  22. printf("strlen(wrdbuf) = %d\n",strlen(wrdbuf));
  23. #endif
  24.     llval = rmval - tival;
  25.     if (outw + w > llval || last >= MAXOUT) {    /* too big */
  26.         last -= outp;
  27.         extra = llval - outw;
  28. #ifdef DEBUG
  29. printf("extra = %d\n",extra);
  30. #endif
  31.         for ( ; outp > 0; outp--)
  32.             if (outbuf[outp-1] == ' ')
  33.                 extra++;
  34.             else
  35.                 break;
  36.         if (rjust == YES) {
  37.             spread(outbuf, outp, extra, outwds);
  38.             if (extra > 0 && outwds > 1)
  39.                 outp += extra;
  40.         }
  41.         brkeol();        /* flush previous line */
  42.     }
  43. #ifdef DEBUG
  44. printf("putwrd: last=%d w=%d outp=%d llval=%d outw=%d extra=%d\n",
  45.         last,w,outp,llval,outw,extra);
  46. #endif
  47.     strcpy(&outbuf[outp],wrdbuf);
  48.     outp = last;
  49.     outw += w;
  50.     outwds++;
  51. }
  52.  
  53.